func jump(nums []int) int {
    ans := 0
    currMaxCover := 0
    nextMaxCover := 0
    for i:=0; i<len(nums)-1; i++ {
        nextMaxCover = max(nextMaxCover, nums[i]+i)
        if currMaxCover == i {
            currMaxCover = nextMaxCover
            ans++
        }
    }
    return ans
}

func max(a int, b int) int {
    if a > b {
        return a
    }
    return b
}